package mi.payment.utils;

import android.text.TextUtils;

import mi.payment.constants.AccountType;
import sunmi.sunmiui.utils.LogUtil;

/**
 * @author Created by Lee64 on 2017/8/22.
 */

public class UnionPayUtil {

    private static final String TAG = "UnionPayUtil";

    /**
     * 获取卡片的账户类型
     */
    public static String getAccountType(String aid) {
        String accountType = AccountType.MAG.getValue();
        if (TextUtils.isEmpty(aid)) {
            return accountType;
        }
        String group = aid.substring(0, 10);
        if ("A000000003".equals(group)) {
            accountType = AccountType.VC.getValue();
        } else if ("A000000004".equals(group) || "A000000005".equals(group)) {
            accountType = AccountType.MC.getValue();
        } else if ("A000000025".equals(group)) {
            accountType = AccountType.AE.getValue();
        } else if ("A000000065".equals(group)) {
            accountType = AccountType.JCB.getValue();
        } else if ("A000000524".equals(group)) {
            accountType = AccountType.RPC.getValue();
        } else if ("A000000333".equals(group)) {
            if ("A000000333010101".equals(aid)) {
                // 借记卡
                accountType = AccountType.DD.getValue();
            } else if ("A000000333010102".equals(aid)) {
                // 贷记卡
                accountType = AccountType.CC.getValue();
            } else if ("A000000333010103".equals(aid)) {
                // 准贷记卡
                accountType = AccountType.SCC.getValue();
            } else if ("A000000333010101".equals(aid)) {
                // 纯电子现金
                accountType = AccountType.EC.getValue();
            }
        }
        LogUtil.e(TAG, "卡片的账户类型 accountType = " + accountType);
        return accountType;
    }

}
